package com.freek.ScreenDrop;
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;

import javax.swing.JTextField;


public class KeyComboField extends JTextField
{
	
	KeyCombo combo;
	
	public KeyComboField(KeyCombo initialCombo)
	{
		this.combo = initialCombo;
		this.addKeyListener(new KeyAdapter()
		{
			@Override
			public void keyPressed(KeyEvent e)
			{
				setCombo(new KeyCombo(e.getKeyCode(), e.getModifiersEx()));
				e.consume();
			}
//			public void keyReleased(KeyEvent e) {
//				combo = new KeyCombo(e.getKeyCode(), e.getModifiersEx());
//				KeyComboField.this.setText(combo.getTextRepresentation());
//				e.consume();
//			};
		});
	}
	
	public KeyCombo getCombo()
	{
		return combo;
	}
	
	public void setCombo(KeyCombo combo)
	{
		this.combo = combo;
		KeyComboField.this.setText(combo.getTextRepresentation());
	}
}
